package java.com.ktjy.text;

import com.ktjy.dao.NewsDao;
import com.ktjy.factory.AbstractFactory;
import java.com.ktjy.factory.SimpleDaoFactory;
import java.com.ktjy.factory.impl.MysqlDaoFactory;
import com.ktjy.pojo.News;
import java.com.ktjy.service.impl.NewsServiceImpl;
import org.junit.Test;

public class NewsServiceImplTest {

    @Test
    public void addNews() throws Exception {
//        NewsDao dao = SimpleDaoFactory.getInstance("mysql");
        AbstractFactory factory = new MysqlDaoFactory();
        NewsDao dao = factory.getInstance();
        NewsServiceImpl service = new NewsServiceImpl();
        service.setDao(dao);

        News news = new News();
        news.setNtitle("测试标题2");
        news.setNcontent("测试内容2");
        service.save(news);
    }
}
